package com.ruoyi.web.controller.sj.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sj.domain.PayRank;
import com.ruoyi.sj.service.IPayRankService;
import com.ruoyi.web.core.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;

/**
 * 充值记录 信息操作处理
 * 
 * @author tyc@yanyu.com
 * @date 2018-11-30
 */
@Controller
@RequestMapping("/sj/payRank")
public class PayRankController extends BaseController
{
    private String prefix = "sj/payRank";
	
	@Autowired
	private IPayRankService payRankService;
	
	@RequiresPermissions("sj:payRank:view")
	@GetMapping()
	public String payRank()
	{
	    return prefix + "/payRank";
	}
	
	/**
	 * 查询充值记录列表
	 */
	@RequiresPermissions("sj:payRank:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PayRank payRank)
	{
		startPage();
        List<PayRank> list = payRankService.selectPayRankList(payRank);
		return getDataTable(list);
	}
	
	/**
	 * 新增充值记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存充值记录
	 */
	@RequiresPermissions("sj:payRank:add")
	@Log(title = "充值记录", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PayRank payRank)
	{		
		return toAjax(payRankService.insertPayRank(payRank));
	}

	/**
	 * 修改充值记录
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		PayRank payRank = payRankService.selectPayRankById(id);
		mmap.put("payRank", payRank);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存充值记录
	 */
	@RequiresPermissions("sj:payRank:edit")
	@Log(title = "充值记录", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PayRank payRank)
	{		
		return toAjax(payRankService.updatePayRank(payRank));
	}
	
	/**
	 * 删除充值记录
	 */
	@RequiresPermissions("sj:payRank:remove")
	@Log(title = "充值记录", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(payRankService.deletePayRankByIds(ids));
	}
	
}
